home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / cad / acadlsp.zip / P-SURF.LSP < prev    next >
Text File  |  1986-11-09  |  3KB  |  125 lines

  1. ;============================ P-SURF.LSP ================================
  2. ;
  3. ;  Patch surface routine for use with AutoCAD Version 2.6
  4. ;
  5. ;  Written by John Lynch   November, 1986
  6. ;
  7. ;
  8. (defun C:P-SURF()
  9.   (setq fl (entget (car (entsel "\nEnter the the first line: "))))
  10.   (setq sl (entget (car (entsel "\nEnter the the second line: "))))
  11.  
  12.   (setq nrow (getint "\nEnter number of faces ALONG lines: "))
  13.   (setq ncol (getint "\nEnter number of faces BETWEEN lines: "))
  14.   (setvar "cmdecho" 0)
  15.   (setvar "blipmode" 0)
  16.  
  17. ;
  18. ;Initilize the beginning points and determine the vecors along the lines.
  19. ;
  20.   (setq bp1 (cdr (assoc 10 fl))
  21.         ep1 (cdr (assoc 11 fl))
  22.         bp2 (cdr (assoc 10 sl))
  23.         ep2 (cdr (assoc 11 sl))
  24.         vl1 (vector ep1 bp1 nrow)
  25.         vl2 (vector ep2 bp2 nrow)
  26.         vpl1 (vector bp2 bp1 ncol)
  27.    )
  28. ;
  29. ;
  30. ;
  31.   (setq m 1)
  32.   (while (<= m nrow)
  33. ;
  34.      (setq
  35.         pl1 (vectadd bp1 vl1)
  36.         pl2 (vectadd bp2 vl2)
  37.         vpl2 (vector pl2 pl1 ncol)
  38.      )
  39. ;
  40. ;---- Initialize the face points
  41. ;
  42.      (setq lpp1 bp1
  43.            lpp2 pl1
  44.            n 1
  45.      )
  46. ;
  47. ;
  48.     (while (<= n ncol)
  49.       (setq upp1 (vectadd lpp1 vpl1)
  50.             upp2 (vectadd lpp2 vpl2)
  51.       )
  52.       (command "3dface" lpp1 lpp2 upp2 upp1 "")
  53.       (setq lpp1 upp1
  54.             lpp2 upp2
  55.             n (1+ n)
  56.       )
  57.     )
  58.  
  59.   (setq bp1 pl1
  60.         bp2 pl2
  61.         vpl1 vpl2
  62.         m (1+ m)
  63.    )
  64.   )
  65.   (setvar "cmdecho" 1)
  66.   (setvar "blipmode" 1)
  67. )
  68.  
  69.  
  70. ;---------------------- VECTOR() -----------------------------
  71. ; Function to determine a vector between two point and divided by m.
  72. ;
  73. (defun vector (ep bp m / x1 x2 y1 y2 z1 z2 dx dy dz)
  74. ;
  75. ; bp : The beginnning point of the line.
  76. ; ep : The end point of the line.
  77. ; m  : The number of divisions in the line.
  78. ;
  79. ;
  80. ;
  81.   (setq x1 (car bp)
  82.         y1 (cadr bp)
  83.         z1 (caddr bp)
  84.   )
  85.   (setq x2 (car ep)
  86.         y2 (cadr ep)
  87.         z2 (caddr ep)
  88.   )
  89. ;
  90.   (setq dx (/ (- x2 x1) m)
  91.         dy (/ (- y2 y1) m)
  92.         dz (/ (- z2 z1) m)
  93.   )
  94.   (list dx dy dz)
  95. ;
  96. )
  97.  
  98. ;-----------------------------VECTADD() ------------------------------
  99. ;  Function to add a vector to a point.
  100. ;
  101. (defun vectadd(bp vec / x1 x2 y1 y2 z1 z2 dx dy dz)
  102. ;
  103. ; bp  : Beginning point assumed to be a list of three reals.
  104. ; vec : Vector to add to the point assumed to be the same.
  105.   (setq x1 (car bp)
  106.         y1 (cadr bp)
  107.         z1 (caddr bp)
  108.   )
  109.   (setq x2 (car vec)
  110.         y2 (cadr vec)
  111.         z2 (caddr vec)
  112.   )
  113. ;
  114.   (setq dx (+ x1 x2)
  115.         dy (+ y1 y2)
  116.         dz (+ z1 z2)
  117.   )
  118.   (list dx dy dz)
  119. )
  120.  
  121.  
  122.  
  123.  
  124.  
  125.